interface SliderStandard {
    //最小宽度
    min:number,
    //最大宽度
    max:number,
    //伸展状态
    status?:boolean
}

export default function onResize(sliderElement:any,mainElement:any) {

    /*点击事件*/
    const setClickStyle = (dom: SliderStandard):void =>{
        let windowWidth = document.body.offsetWidth;
        if(dom.status) {
            sliderElement.value.style.width = dom.min + 'px';
            mainElement.value.style.width = windowWidth - dom.min + 'px';
        } else {
            sliderElement.value.style.width = dom.max + 'px';
            mainElement.value.style.width = windowWidth - dom.max + 'px';
        }
    }
    /*窗口改变事件主页窗口style*/
    const setResizeStyle = (dom: SliderStandard):boolean => {
        let windowWidth = document.body.offsetWidth;
        if( windowWidth >= 768 && windowWidth <= 992 ) {
            sliderElement.value.style.width = dom.min + 'px';
            mainElement.value.style.width = windowWidth - dom.min + 'px';
            return true;
        } else if( windowWidth <= 768){
            sliderElement.value.style.width = 0
            mainElement.value.style.width = windowWidth + 'px';
            return true;
        } else {
            sliderElement.value.style.width = dom.max + 'px';
            mainElement.value.style.width = windowWidth - dom.max + 'px';
            return false;
        }
    }

    return {
        setResizeStyle,
        setClickStyle
    }
}
